/**
 * 文件名：MD5CredentialsMatcher.java
 * 版权：Copyright 2014 EasyUnion
 * 描述：<描述>
 * 修改人：bony
 * 修改时间：2014年7月20日
 * 修改内容：<修改内容>
 */
package com.jfinal.ext.shrio;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

import com.jfinal.common.util.MD5Utils;

public class MD5CredentialsMatcher extends SimpleCredentialsMatcher {
	@Override
	public boolean doCredentialsMatch(AuthenticationToken token,
			AuthenticationInfo info) {
		Object tokenCredentials = encrypt(new String(
				toBytes(token.getCredentials())));
		Object accountCredentials = getCredentials(info);
		return equals(tokenCredentials, accountCredentials);
	}

	private Object encrypt(String pass) {
		return MD5Utils.getPwd(pass);
	}
	
	 
}
